<template>
  <div class="">
    <el-tabs v-model="activityName" type="border-card" @tab-click="tabChange">
      <el-tab-pane name="/makeCardRecord" v-hasPermission="'management_batchCardRecord:show'" label="制卡记录">
        <div class="page-content">
          <router-view v-if="selectMaterials()"></router-view>
        </div>
      </el-tab-pane>
      <el-tab-pane name="/dispatchingRecord" v-hasPermission="'management_deliveryRecord:show'" label="配送记录">
        <div class="page-content">
          <router-view v-if="selectCategorys()"></router-view>
        </div>
      </el-tab-pane>

    </el-tabs>
  </div>
</template>
<script>
  //注意路径
  export default {
    data() {
      return {
        activityName: "/makeCardRecord"
      };
    },
    watch: {
      $route(newValue, oldValue) {
        var path = this.$route.fullPath;
        if (path == "/batchSizeVip") {
          this.goHome();
          return;
        }
        if (path.startsWith("/makeCardRecord")) {
          this.activityName = "/makeCardRecord";
        } else if (path.startsWith("/dispatchingRecord")) {
          this.activityName = "/dispatchingRecord";
        } else {
          this.activityName = this.$route.fullPath;
        }
      }
    },
    created() {
      window.this = this;
      console.log(this.$route);
      // this.activityName=this.$route.fullPath;
      this.goHome();
    },
    methods: {
      goBack() {
        this.router.go(-1);
      },
      goHome() {
        this.activityName = "/makeCardRecord";
        this.router.push({ path: "/makeCardRecord/dataTable" });
      },
      tabChange(active) {
        this.activityName = active.name;
        if (active.name == "/makeCardRecord") {
          this.router.push({ path: "/makeCardRecord/dataTable" });
        } else if (active.name == "/dispatchingRecord") {
          this.router.push({ path: "/dispatchingRecord/dataTable" });
        }else {
          this.router.push({ path: active.name});
        }
      },
      selectMaterials(){
        return this.activityName.startsWith("/makeCardRecord");
      },
      selectCategorys(){
        return this.activityName.startsWith("/dispatchingRecord");
      },

    }
  };
</script>
<style scoped>
</style>
